﻿<!DOCTYPE HTML>
<html>
<head>
	{include file="Public/header"/}
	<title>访问授权</title>
</head>
<body>
<article class="page-container">
	<form method="post" class="form form-horizontal" id="form-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">访问授权：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{volist name="data_list" id="value" key="key"}
				<dl class="permission-list">
					<dt>
						<label><input type="checkbox" value="{$value['id']}" name="rules[]" id="user-Character-{$key}">&nbsp;{$value['title']}&nbsp;</label>
					</dt>
					<dd>
						{present name="value['children']"}
						{volist name="value['children']" id="val" key="ke"}
						<dl class="cl permission-list2">
							<dt>
								<label class=""><input type="checkbox" value="{$val['id']}" name="rules[]" id="user-Character-0-{$ke}">&nbsp;{$val['title']}&nbsp;</label>
							</dt>
							{present name="val['children']"}
							<dd>
								{volist name="val['children']" id="v" key="k"}
								<label class="">&nbsp;
									<input type="checkbox" value="{$v['id']}" name="rules[]" id="user-Character-1-0-{$k}">&nbsp;{$v['title']}&nbsp;</label>
								{/volist}
							</dd>
							{/present}
						</dl>
						{/volist}
						{/present}
					</dd>
				</dl>
				{/volist}
			</div>
		</div>
		<input type="hidden" name="id" value="{$group_id}">
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<button type="submit" class="btn btn-success radius" id="admin-role-save"><i class="icon-ok"></i> 确定</button>
			</div>
		</div>
	</form>
</article>

{include file="Public/footer" /}

<!--请在下方写此页面业务相关的脚本-->
{include file="Public/expand-js" /}
<script type="text/javascript">
    $(function(){
		//表单验证
		$("#form-add").validate({
			onkeyup:false,
			focusCleanup:true,
			success:"valid",
			submitHandler:function(form){
				var data = $('#form-add').serialize();
				$(form).ajaxSubmit(function(data){
					if(data.code)
					{
						layer.msg(data.msg);
						setTimeout(function(){
							window.parent.location.reload();
							window.location=data.opt.url;
						}, 2000);
					} else {
						layer.msg(data.msg);
					}
				});
			}
		});
        $(".permission-list dt input:checkbox").click(function(){
            $(this).closest("dl").find("dd input:checkbox").prop("checked",$(this).prop("checked"));
        });
        $(".permission-list2 dd input:checkbox").click(function(){
            var l =$(this).parent().parent().find("input:checked").length;
            var l2=$(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
            if($(this).prop("checked")){
                $(this).closest("dl").find("dt input:checkbox").prop("checked",true);
                $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",true);
            }
            else{
                if(l==0){
                    $(this).closest("dl").find("dt input:checkbox").prop("checked",false);
                }
                if(l2==0){
                    $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",false);
                }
            }
        });
    });

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>